﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Core.Handlers
{
    /// <summary>
    /// 审计日志格式处理
    /// </summary>
    public abstract class AuditLogFormatHandler
    {
        /// <summary>
        /// 获取行关键数据
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="entityValues">数据库值集合</param>
        /// <param name="formatArgs">格式化参数</param>
        /// <returns></returns>
        public virtual string GetRowKey(DbContext context, object entityValues, params string[] formatArgs) => null;

        /// <summary>
        /// 获取变更值
        /// </summary>
        /// <param name="context">数据上下文</param>
        /// <param name="oldValue"></param>
        /// <param name="newValue"></param>
        /// <returns></returns>
        public virtual string[] GetChangeValue(DbContext context, object oldValue, object newValue)
            => new string[2] { oldValue?.ToString(), newValue?.ToString() };
    }
}
